\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{macros}[1998/01/01 Conjunto de macros creadas por
ALFREDO SANCHEZ ALBERCA para la Universidad San Pablo CEU]

\RequirePackage{amssymb}
\RequirePackage{amsmath}
\RequirePackage{color}
\RequirePackage{ntheorem}
\RequirePackage{verbatim}
\RequirePackage{fancyvrb}

\newtheorem{definition}{Definici\'on}
\newtheorem{definicion}{Definici\'on}
\newtheorem{remark}{Observaci\'on}
\newtheorem{observacion}{Observaci\'on}
\newtheorem{teorema}{Teorema}
\newtheorem{lema}{Lema}
\newtheorem{corolario}{Corolario}



\theoremstyle{nonumberplain}
\newtheorem{teoremasn}{Teorema}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\blacksquare}}
\theoremseparator{}
\newtheorem{example}{Ejemplo}
\newtheorem{ejemplo}{Ejemplo}
\theoremstyle{plain}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\blacksquare}}
\theoremseparator{}
\newtheorem{ejercicio}{Ejercicio}


\newcommand{\encabezado}[1]
%Crea encabezados de p\'{a}gina personalizados
%Ejemplo \encabezado{Universidad San Pablo CEU\hfill Dpto. CC.
%B\'{a}sicas.}
{
    \renewcommand{\ps@myheadings}
    {
        \renewcommand{\@oddhead}{\slshape \rightmark}
        \renewcommand{\@oddfoot}{\centerline \thepage}
    }
    \pagestyle{myheadings}
    \markright{#1}
}

\newcommand{\hoja}[3]
%Crea el encabezado para hojas de ejercicios, de pr\'{a}cticas o
%parecidos.
%Ejemplo: \hoja{Tipo de hoja}{Nº de hoja}{Titulo de la hoja}
{
    \begin{flushleft}
        {\LARGE \textsf{#1}} {\huge #2}
        \vspace{.1cm}
        \hrule height2pt
    \end{flushleft}
    \begin{flushright}
        \textbf{{\huge #3}}
    \end{flushright}
    \vskip.5cm
}

\newlength{\titulolength}
\newcommand{\practica}[3][gray]
%Crea el encabezado para pr\'{a}cticas
%Ejemplo: \hoja{Tipo de práctica}{Titulo de la práctica}
{
	\setlength{\fboxsep}{5pt}
    \setlength{\titulolength}{\textwidth}
	\addtolength{\titulolength}{-2\fboxsep}
	\addtolength{\titulolength}{-2\fboxrule}
%        \hrule height2pt
%        \vspace{.5mm}
%        \hrule height.5pt
%        \vspace{2mm}
        \hfill \textsl{\textsf{{\LARGE #2}}}\\
		\colorbox{#1}{
		\begin{minipage}{\titulolength}
			\raggedleft \rule{0mm}{10mm} \textcolor{white}{\textbf{\textsf{\huge #3}}}
		\end{minipage}
		}
%        \vspace{1mm}
%        \hrule height.5pt
%        \vspace{.5mm}
%        \hrule height2pt
    
    \bigskip
}

\newcommand{\examen}[4]
%Crea el encabezado para examenes.
%Ejemplo: \examen{Nombre del Examen}{Curso}{Fecha}{Modelo}
{
    {\centering \textbf{{\Large #1}} \\[.4cm]
    \textbf{#2} \hfill \textbf{#4} \hfill \textbf{#3} \\[.4cm]
    Nombre: \hspace{8cm} \hfill DNI: \hspace{2cm} \hfill Grupo:\qquad\qquad
    \vspace{.2cm}
    \hrule height 2pt
    \vspace{1cm}}
}

\newcommand{\puntos}[1]
%Pone los puntos de un ejercicio en el margen izquierdo.
{\reversemarginpar \renewcommand{\marginparsep}{-.4cm}\rule{-3.8pt}{0pt}\marginpar{($#1$ pts.)}}

\newcommand{\exasol}[4]
%Crea el encabezado para la solucion de examenes.
%Ejemplo: \examen{Nombre del Examen}{Curso}{Fecha}{Modelo}
{
    {\centering \textbf{{\Large \textcolor{blue}{#1}}} \\[.4cm]
    \textbf{#2} \hfill #4 \hfill \textbf{#3}
    \vspace{.2cm}
    \hrule height 2pt
    \vspace{1cm}}
}

\newenvironment{solucion}
{
    \par
    \bigskip
    \noindent \colorbox{red}{\color{white}\textbf{\textsf{SOLUCI\'{O}N}}}
    \color{black} \medskip \nopagebreak \par
}
{\par \hfill \color{red}\rule{5mm}{1mm} \bigskip}

\newenvironment{ejercicios}
{
    \newcounter{contador}
    \begin{list}{\thecontador.}{\usecounter{contador}
    \setlength{\leftmargin}{0cm}}
}
{
    \end{list}
}

\newenvironment{programa}
{\tt \begin{tabbing}
    aaa \= aaa \= aaa \= aaa \= aaa  \= aaa \= aaa \= aaa \= \kill }
{\end{tabbing}\rm}

\newlength{\codigolength}
\newenvironment{codigo}{%
  \setlength{\codigolength}{\textwidth}
  \addtolength{\codigolength}{-\leftmargin}
  \addtolength{\codigolength}{-8\fboxsep}
  \addtolength{\codigolength}{-2\fboxrule}
  \par\noindent\minipage{\linewidth}\verbatim}
{\endverbatim\endminipage}

\newcommand{\asigna}{\(\leftarrow\)}

\newlength{\indicacionlength}
\newenvironment{indicacion}[1]{
\setlength{\indicacionlength}{\linewidth}
  \addtolength{\indicacionlength}{-2\fboxsep}
  \addtolength{\indicacionlength}{-2\fboxrule}
    \par\noindent
    \colorbox[gray]{0.90}{\parbox{\indicacionlength}{\footnotesize \textbf{Indicaci\'on}\nopagebreak\par\noindent
    #1}}
    \medskip
}
{}

\DefineVerbatimEnvironment{salida}{Verbatim}{frame=single, formatcom=\color{blue}, rulecolor=\color{green},framesep=.5cm, fontsize=\footnotesize, label=Salida, commandchars=\\\{\}}

\newlength{\anchurarecuadro}
\newlength{\grosorrecuadro}
\newcommand{\recuadro}[4]{
  \setlength{\anchurarecuadro}{#2}
  \setlength{\grosorrecuadro}{#1}
  \fboxrule\grosorrecuadro
%  \def\hrulefill{\leaders\hrule height\grosorrecuadro \hfill}
  \addtolength{\anchurarecuadro}{2\grosorrecuadro}
%  \addtolength{\anchurarecuadro}{2\
  \vbox{\hbox{\vbox to 0pt{
    \hbox to \anchurarecuadro{\hrulefill \raisebox{-\fboxsep}{\bfseries #3}\hrulefill}}}
    \hbox{\vrule width \grosorrecuadro \vbox{
      \vfill \hbox to #2{\hss\parbox{.9\anchurarecuadro}{#4}\hss} \vfill\hbox to #2{\hrulefill}}
      \vrule width \grosorrecuadro
}}}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% MACROS PARA LOS GUIONES DE PRACTICAS %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\menu}[1]{\texttt{#1}}
\newcommand{\opcion}[1]{\texttt{#1}}
\newcommand{\comando}[1]{\texttt{#1}}
\newcommand{\variable}[1]{\textsf{#1}}
\newcommand{\boton}[1]{\textsf{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% MACROS PARA EXPRESIONES MATEMATICAS %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\sen}{\mathop{\rm sen}\nolimits}
\newcommand{\arcsen}{\mathop{\rm arcsen}\nolimits}
\newcommand{\tg}{\mathop{\rm tg}\nolimits}
\newcommand{\arctg}{\mathop{\rm arctg}\nolimits}
\newcommand{\cosec}{\mathop{\rm cosec}\nolimits}
\newcommand{\cotg}{\mathop{\rm cotg}\nolimits}
\newcommand{\dom}{\mathop{\rm Dom}\nolimits}
\newcommand{\im}{\mathop{\rm Im}\nolimits}
\newcommand{\N}{I\!\!N}
\newcommand{\Z}{\mbox{\sffamily Z$\!\!$Z}}
\newcommand{\R}{I\!\!R}
%\newcommand{\dfrac}[2]{{\displaystyle \frac{#1}{#2}}}
\newcommand{\dint}{\displaystyle \int}
\newcommand{\dlim}{\displaystyle \lim}
%\newcommand{\binom}[2]{{#1 \choose #2}}
